 DIDO Linux Tool User Guide
====================================================
                                        v 1.0

This document contains information about MB1 DIDO hardware placement, 
and how to use the linux tool.

1. System Requirements
  
  -OS  

   Linux Mint 19.2 "Tina" Xface  x64 

  -UI

   Linux shell with root privilege

  


2. Delivery contents

    File Name                                Description
======================  =====================================================  
   MB1_DIDO               Linux ELF executeable 64bit for DIDO function.
   User Guide.txt         This document  
   src/*.*                Source code 

PS * : To ensure integrity of linux executeable, tool package is compressed in tgz format for
       delivery. To extract it by using command  "tar zxvf xxxx.tgz " in Linux.  
       

3.  Hardware placement

DIDO boards position on Mother board :

    +---------------------+
    |                     |
    |       +-----+       |
    |       | CPU |       |
    |       +-----+       |
    |                     |
    |       +-----+       |
    |       | BRD |       |
    +-------+-----+-------+


DIDO board pin definition:

    +===================================================+
    |  10    9    8    7    6    5    4    3    2    1  |
    +===================================================+
       |     |    |    |    |    |    |    |    |    |
      GND   DI4  DI3  DI2  DI1  DO4  DO3  DO2  DO1  VCC

   PIN    HW     ID      Description
  =====  =====  =====  ========================
  PIN1   VCC             VCC
  PIN2	 DO_1    01      Digital Output 1
  PIN3	 DO_2    02      Digital Output 2
  PIN4	 DO_3    03      Digital Output 3
  PIN5	 DO_4    04      Digital Output 4
  PIN6	 DI_1    11      Digital Input 1
  PIN7	 DI_2    12      Digital Input 2
  PIN8	 DI_3    13      Digital Input 3
  PIN9	 DI_4    14      Digital Input 4
  PIN10  GND             Ground


Note: Due to ioslated circuit, each pin is fixed to its usage(Input or Output) as HW definition.
      It is impossible to overdrive the signal by altering its direction. For example,
      PIN 1 (DI_1) cannot set to output pin or set its high/low. PIN 2 (DO_1) cannot set
      to input pin to receive signal.


4.  USAGE

4.1. Appilication Options:

*** Note : This tool must run under root privilege ***

  Options:
  -h, -?       : Help information.
  -get n       : Get GPIO PIN n status. n = 01~04 or 11~14
  -set n in    : Set GPIO PIN n as input. n = 11~14
  -set n out v : Set GPIO PIN n as output, and value = v (1 or 0).
  -all         : Show all DIDO status.



4.2. Example: *** Note : This tool must run under root privilege ***

  4.2-1. Get DIO board DI_2 (PIN 7) status,

       ./MB1_DIDO -get 12

  Result:
       
       GP12 : Input(0)  Low(0)

  4.2-2. Set DIO board  DO_4 (PIN 5) to high,

       ./MB1_DIDO -set 04 out 1
  

  4.2-3. Show all DIDO status ,
       ./MB1_DIDO -all

  Result:
  Borad DIO Status :
             OOOO-IIII
      DIO    1234-1234
             ==== ====
     In/Out: OOOO IIII
     Level : 0001 0000




Appendix:

============================
  Factory test cases design
=============================

Purpose: Make DIDO test board to cross-verify the DIDO functions.

Procedure:
 1. Connect the DIDO board to the DIDO test board.

 2. Install Board; Set PINs 6, 7, 8, 9 as Input; PINs 1, 2, 3, 4 as Output.
    Case A: Set all Output level to Low; It is expected that other input PINs should be pulled low,
            and eventually all PINs levels should be 0 and LED 1-4 on DIDO test board are all on.

       ./MB1_DIDO -set 11 in
       ./MB1_DIDO -set 12 in
       ./MB1_DIDO -set 13 in
       ./MB1_DIDO -set 14 in
       ./MB1_DIDO -set 01 out 0
       ./MB1_DIDO -set 02 out 0
       ./MB1_DIDO -set 03 out 0
       ./MB1_DIDO -set 04 out 0
       ./MB1_DIDO -all

  Result:
  Borad DIO Status :
             OOOO-IIII
      DIO    1234-1234
             ==== ====
     In/Out: OOOO IIII
     Level : 0000 0000


    Case B: Set all Output level to High; It is expected that other input PINs should be pulled high,
            and eventually all PINs levels should be 1 and LED 1-4 on DIDO test board are all off.

       ./MB1_DIDO -set 01 out 1
       ./MB1_DIDO -set 02 out 1
       ./MB1_DIDO -set 03 out 1
       ./MB1_DIDO -set 04 out 1
       ./MB1_DIDO -all

  Result:
  Borad 1 DIO Status :
             OOOO-IIII
      DIO    1234-1234
             ==== ====
     In/Out: OOOO IIII
     Level : 1111 1111

 3. Use the button of the DIDO test board to verify DIO
    Case A: 1) Set all Output level to High; It is expected that other input PINs should be pulled high,
               and eventually all PINs levels should be 1 and LED 1-4 on DIDO test board are all off.

       ./MB1_DIDO -set 01 out 1
       ./MB1_DIDO -set 02 out 1
       ./MB1_DIDO -set 03 out 1
       ./MB1_DIDO -set 04 out 1
       ./MB1_DIDO -all

  Result:
  Borad 1 DIO Status :
             OOOO-IIII
      DIO    1234-1234
             ==== ====
     In/Out: OOOO IIII
     Level : 1111 1111

            2) Press button 1 and don't release button and the GPI 1 PIN levels should be 0

       ./MB1_DIDO -all

  Result:
  Borad 1 DIO Status :
             OOOO-IIII
      DIO    1234-1234
             ==== ====
     In/Out: OOOO IIII
     Level : 1111 0111

    Case B: Release button 1 and the GPI 1 PIN levels should be 1

       ./MB1_DIDO -all

  Result:
  Borad 1 DIO Status :
             OOOO-IIII
      DIO    1234-1234
             ==== ====
     In/Out: OOOO IIII
     Level : 1111 1111
